import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsEnum, IsString, IsNumber, Min, Max } from 'class-validator';
import { Type } from 'class-transformer';
import { ImportStatus, MatchFileType } from '../entities/match-import-record.entity';

/**
 * 查询导入记录DTO
 */
export class QueryImportRecordDto {
  @ApiProperty({ 
    description: '页码', 
    example: 1, 
    required: false,
    default: 1 
  })
  @IsOptional()
  @Type(() => Number)
  @IsNumber({}, { message: '页码必须是数字' })
  @Min(1, { message: '页码不能小于1' })
  page?: number = 1;

  @ApiProperty({ 
    description: '每页数量', 
    example: 10, 
    required: false,
    default: 10 
  })
  @IsOptional()
  @Type(() => Number)
  @IsNumber({}, { message: '每页数量必须是数字' })
  @Min(1, { message: '每页数量不能小于1' })
  @Max(100, { message: '每页数量不能超过100' })
  limit?: number = 10;

  @ApiProperty({ 
    description: '文件类型', 
    enum: MatchFileType, 
    required: false 
  })
  @IsOptional()
  @IsEnum(MatchFileType, { message: '文件类型不正确' })
  fileType?: MatchFileType;

  @ApiProperty({ 
    description: '导入状态', 
    enum: ImportStatus, 
    required: false 
  })
  @IsOptional()
  @IsEnum(ImportStatus, { message: '导入状态不正确' })
  status?: ImportStatus;

  @ApiProperty({ 
    description: '配置ID', 
    required: false 
  })
  @IsOptional()
  @Type(() => Number)
  @IsNumber({}, { message: '配置ID必须是数字' })
  configId?: number;

  @ApiProperty({ 
    description: '文件名关键词搜索', 
    required: false 
  })
  @IsOptional()
  @IsString()
  fileName?: string;
}